import { fetcher } from '@/src/utils/fetcher'
import { cookies } from 'next/headers'
import Article from './components/article'

const Page: React.FC = async () => {
  const cookieStore = cookies()
  const news = await fetcher<News[]>('/api/index/indexContent?type=news', {
    cookieStore,
  })
  return (
    <>
      {news.map((item) => {
        return (
          <Article
            key={item.id}
            id={item.id.toString()}
            picture={item.image}
            category={item.class_name}
            title={item.title}
            desc={item.con}
            createdAt={item.createtime}
          />
        )
      })}
    </>
  )
}

export default Page
